Replace single matches by ifs
authormcarton <cartonmartin+git@gmail.com>
Fri, 15 Jan 2016 15:01:31 +0000 (16:01 +0100)
committermcarton <cartonmartin+git@gmail.com>
Sat, 16 Jan 2016 11:48:35 +0000 (12:48 +0100)
Fix all Clippy’s single_match warnings.

src/cargo/sources/git/source.rs

index e2829ad5be7d2bfaf6a28040ebed10fcc8c230a4..4a66b1c3159202c919eff5de890634ca6b208d6e 100644 (file)
@@ -101,13 +101,10 @@ pub fn canonicalize_url(url: &Url) -> Url {
     let mut url = url.clone();
 
     // Strip a trailing slash
-    match url.scheme_data {
-        url::SchemeData::Relative(ref mut rel) => {
-            if rel.path.last().map(|s| s.is_empty()).unwrap_or(false) {
-                rel.path.pop();
-            }
+    if let url::SchemeData::Relative(ref mut rel) = url.scheme_data {
+        if rel.path.last().map(|s| s.is_empty()).unwrap_or(false) {
+            rel.path.pop();
         }
-        _ => {}
     }
 
     // HACKHACK: For github URL's specifically just lowercase
@@ -117,32 +114,26 @@ pub fn canonicalize_url(url: &Url) -> Url {
     // same case conversion rules that GitHub does. (#84)
     if url.domain() == Some("github.com") {
         url.scheme = "https".to_string();
-        match url.scheme_data {
-            url::SchemeData::Relative(ref mut rel) => {
-                rel.port = Some(443);
-                rel.default_port = Some(443);
-                let path = mem::replace(&mut rel.path, Vec::new());
-                rel.path = path.into_iter().map(|s| {
-                    s.chars().flat_map(|c| c.to_lowercase()).collect()
-                }).collect();
-            }
-            _ => {}
+        if let url::SchemeData::Relative(ref mut rel) = url.scheme_data {
+            rel.port = Some(443);
+            rel.default_port = Some(443);
+            let path = mem::replace(&mut rel.path, Vec::new());
+            rel.path = path.into_iter().map(|s| {
+                s.chars().flat_map(|c| c.to_lowercase()).collect()
+            }).collect();
         }
     }
 
     // Repos generally can be accessed with or w/o '.git'
-    match url.scheme_data {
-        url::SchemeData::Relative(ref mut rel) => {
-            let needs_chopping = {
-                let last = rel.path.last().map(|s| &s[..]).unwrap_or("");
-                last.ends_with(".git")
-            };
-            if needs_chopping {
-                let last = rel.path.pop().unwrap();
-                rel.path.push(last[..last.len() - 4].to_string())
-            }
+    if let url::SchemeData::Relative(ref mut rel) = url.scheme_data {
+        let needs_chopping = {
+            let last = rel.path.last().map(|s| &s[..]).unwrap_or("");
+            last.ends_with(".git")
+        };
+        if needs_chopping {
+            let last = rel.path.pop().unwrap();
+            rel.path.push(last[..last.len() - 4].to_string())
         }
-        _ => {}
     }
 
     url